package com.thymeleaf.demo.controller;


import com.thymeleaf.demo.model.Goods;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.servlet.ModelAndView;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author sunny
 * @since 2020-12-22
 */
@Controller
@RequestMapping("/goods")
public class GoodsController {

    @GetMapping("detail")
    public ModelAndView detail(){
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("goods/detail");

        Goods goods = new Goods();
        goods.setGoodsName("测试商品");
        goods.setDescription("描述");

        modelAndView.addObject("goods",goods);
        
//        return new ModelAndView("goods/detail", "goods", goods);
        return modelAndView;
    }

}
